const app = getApp()

Page({
	data: {
		is_iphonex: app.globalData.is_iphonex,
		navbarData: {
			showCapsule: 1, 
			title: '体检报告历史'
		},
		navHeight: app.globalData.statusBarHeight * 2 + 86,
		listData: null
	},
	onLoad: function (options) {
		this.showLoading()
		this.getHistoryList()
			.then(res => {
				wx.hideLoading()
				this.setData({ listData: res })
			})
			.catch(err => {
				wx.hideLoading()
				this.showToast('拉取体检报告历史失败')
			})
			.finally(() => {
				wx.hideLoading()
			})
	},
	/**
	 * 获取体检报告历史页面
	 */
	getHistoryList: function () {
		return new Promise((resolve, reject) => {
			wx.request({
				url: app.getUrl('/xcx/guidance/guidanceHis'),
				method: "GET",
				header: wx.getStorageSync('cookie'),
				success: function (res) {
					res.data.code === 0 ? resolve(res.data.data) : reject()
				},
				fail: function (err) {
					reject(err)
				}
			})
		})
	},
	/**
	 * 显示加载
	 */
	showLoading: function () {
		wx.showLoading({
		  title: '加载中...',
		  icon: 'none'
		})
	},
})